<?php
/**
 * 处理系统错误
 * @version Terry<wanghui@weimob.com>
 * @date 2016-08-11
 */
namespace app\common;
use Yii;
use yii\base\Action;

class ErrorHandler extends Action {

	public $array_of_exceptions = [];

	public $defaultErrorAction = 'yii\web\ErrorAction';

	public function run()
	{
		$e = \Yii::$app->getErrorHandler()->exception;
		$currentExceptionCode = \Yii::$app->getErrorHandler()->exception->statusCode;
		$exceptionArr = [
			"code" => $currentExceptionCode,
			"statusCode" => $currentExceptionCode,
			'message' => $e->getMessage(),
			'file' => $e->getFile() . ', line: ' . $e->getLine(),
			'trace' => $e->getTraceAsString(),
		];
		return $this->controller->render("error", $exceptionArr);
	}
}